<?PHP
/**
 *  溯源规则
 */
class Admin_srule_Controller extends controller_admin{
	function __construct(){
		parent::__construct();
	 	$this->assign('nav','溯源规则');
		$this->assign('menuid1','6');
		$this->assign('menuid2','5'); 
		//权限判断
		factory::module('admin')->authSys('source_setup'); 
	}
	
	##################################
	/* 溯源规则-菜品  */
	##################################
	function vege__(){
		$db = factory::getDBO();
		$this->assign('rs',$db->loadassoclist('select * from `t_vegetype` order by show_index asc'));
	} 
	##################################
	/* 修改溯源规则-菜品  */
	##################################
	function vegemodify__(){
		if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST')
		{
			$forms = format::addslash_json(json_decode( stripslashes($_POST['forms']) ));
			$db = factory::getdbo();
			$db->begin(); 
			if(is_array($forms)){
				foreach($forms as $v){
					if(!$db->update('vegetype',$v)){
						$db->rollback();
						exit('服务器开小差了，请稍后再尝试！');
					}					
				}
			}
			$db->commit();
			exit('{"success":"1"}');
		}
		$db = factory::getDBO();
		$this->assign('rs',$db->loadassoclist('select * from `t_vegetype` order by show_index asc'));	
		 
	} 
	 
	
	##################################
	/* 溯源规则-小区  */
	##################################
	function send__(){
		$db = factory::getDBO();
		$this->assign('rs',$db->loadassoclist('select * from `t_list_zone` order by show_index asc'));
	} 
	##################################
	/* 修改溯源规则-小区  */
	##################################
	function sendmodify__(){
		if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST')
		{
			$forms = format::addslash_json(json_decode( stripslashes($_POST['forms']) ));
			$db = factory::getdbo();
			$db->begin(); 
			if(is_array($forms)){
				foreach($forms as $v){
					if(!$db->update('list_zone',$v)){
						$db->rollback();
						exit('服务器开小差了，请稍后再尝试！');
					}					
				}
			}
			$db->commit();
			exit('{"success":"1"}');
		}
		$db = factory::getDBO();
		$this->assign('rs',$db->loadassoclist('select * from `t_list_zone` order by show_index asc'));
	} 
	
	
	
	
	
	
	
	
	 
	
}
?>